/*
--------------------------------------------------------------------------------
				Ak-Lib. 
			 Project       	: Ak-Lib
			 Group         	: Ak-Lib R&D Team
			 Author        	: Ocean.Wang
			 Create Date 	: 05-01-2010
--------------------------------------------------------------------------------
Code Name 	:  A.K 	~v~
Description	:  Yet Another Cross-Platform Lib.
Cautions    	:
--------------------------------------------------------------------------------
Change History:
Version		: 0.1
Building 		: 05/01/10
10-05.01 first draft, build, debug and test.
--------------------------------------------------------------------------------
*/

#include "ak_xml2.h"

static 	void * 	_test_CbChild(void * pCookie, unsigned char * pName, int id)
{
	return pCookie;
}

static 	int 	_test_CbAttr(void * pCookie, unsigned char * pName, int id, unsigned char * pValue)
{
	return 0;
}

/*
--------------------------------------------------------------------------------
Semistatic TF.
*/
static 	char * 			_gAttr_SemistaticTF_Information[]={
	"rateMatchingAttribute", 
	"crc-Size", 
	"channelCodingType", 
	"CodingRate"
};

static 	_t_xml_desc 	_gDesc_SemistaticTF_Information = {
	/* Name */
	"SemistaticTF-Information",
	/* Attribute */
	{4, _gAttr_SemistaticTF_Information},
	
	/* Children */
	{0, NULL},
		
	/* CallBack */
	(void * (*)())_test_CbChild,
	(void *	(*)())_test_CbAttr,
};


/*
--------------------------------------------------------------------------------
TFS Element.
*/
static	char *			_gAttr_RlcSize[]={
	"type", 
	"sizeType", 
	"part1", 
	"part2"
};
static 	_t_xml_desc 	_gDesc_RlcSize = {
	/* Name */
	"rlc-Size",
	/* Attribute */
	{4, _gAttr_RlcSize},

	/* Children */
	{0, NULL},

	/* CallBack */
	(void * (*)())_test_CbChild,
	(void *	(*)())_test_CbAttr,
};

static	char *			_gAttr_NumberOfTransportBlocks[]={
	"n", 
};
static 	_t_xml_desc 	_gDesc_NumberOfTransportBlocks = {
	/* Name */
	"NumberOfTransportBlocks",
	/* Attribute */
	{1, _gAttr_NumberOfTransportBlocks},
	
	/* Children */
	{0, NULL},

	/* CallBack */
	(void * (*)())_test_CbChild,
	(void *	(*)())_test_CbAttr,
};

static	char *			_gAttr_LogicalChannelList[]={
	"type", 
	"explicitList"
};
static 	_t_xml_desc 	_gDesc_LogicalChannelList = {
	/* Name */
	"LogicalChannelList",
	/* Attribute */
	{2, _gAttr_LogicalChannelList},

	/* Children */
	{0, NULL},

	/* CallBack */
	(void * (*)())_test_CbChild,
	(void *	(*)())_test_CbAttr,
};


/*
--------------------------------------------------------------------------------
Deficate TransCh TFS.
*/
static 	_t_xml_desc *	_gChild_DedicatedDynamicTF_Info[] = {
	&_gDesc_RlcSize,
	&_gDesc_LogicalChannelList,
	&_gDesc_NumberOfTransportBlocks
};

static	char *			_gAttr_DedicatedDynamicTF_Info[]={
	"numberOfTbSizeList"
};

static 	_t_xml_desc 	_gDesc_DedicatedDynamicTF_Info = {
	/* Name */
	"DedicatedDynamicTF-Info",
	/* Attribute */
	{1, _gAttr_DedicatedDynamicTF_Info},
	
	/* Children */
	{3, _gChild_DedicatedDynamicTF_Info},

	/* CallBack */
	(void * (*)())_test_CbChild,
	(void *	(*)())_test_CbAttr,
};


static 	_t_xml_desc *	_gChild_DedicatedTransChTFS[] = {
	&_gDesc_SemistaticTF_Information,
	&_gDesc_DedicatedDynamicTF_Info
};

static	char *			_gAttr_DedicatedTransChTFS[]={
	"tti", 
	"DedicatedDynamicTF-InfoList"
};

static 	_t_xml_desc 	_gDesc_DedicatedTransChTFS ={
	/* Name */
	"DedicatedTransChTFS",

	/* Attribute */
	{2,	_gAttr_DedicatedTransChTFS},
	
	/* Children */
	{2, _gChild_DedicatedTransChTFS},

	/* CallBack */
	(void * (*)())_test_CbChild,
	(void *	(*)())_test_CbAttr,
};


/*
--------------------------------------------------------------------------------
Common TransCh TFS.
*/
static	_t_xml_desc *	_gChild_CommonDynamicTF_Info[] = {
	&_gDesc_RlcSize,
	&_gDesc_LogicalChannelList,
	&_gDesc_NumberOfTransportBlocks
};

static	char *			_gAttr_CommonDynamicTF_Info[]={
	"numberOfTbSizeList"
};

static	_t_xml_desc	_gDesc_CommonDynamicTF_Info = {
	/* Name */
	"CommonDynamicTF-Info",
	/* Attribute */
	{1, _gAttr_CommonDynamicTF_Info},

	/* Children */
	{3, _gChild_CommonDynamicTF_Info},
	
	/* CallBack */
	(void * (*)())_test_CbChild,
	(void *	(*)())_test_CbAttr,
};


static 	_t_xml_desc *	_gChild_CommonTransChTFS[] = {
	&_gDesc_SemistaticTF_Information,
	&_gDesc_CommonDynamicTF_Info
};

static	char *			_gAttr_CommonTransChTFS[]={
	"tti", 
	"CommonDynamicTF-InfoList"
};

static 	_t_xml_desc 	_gDesc_CommonTransChTFS ={
	/* Name */
	"CommonTransChTFS",

	/* Attribute */
	{2,	_gAttr_CommonTransChTFS},

	/* Children */
	{2, _gChild_CommonTransChTFS},
	
	/* CallBack */
	(void * (*)())_test_CbChild,
	(void *	(*)())_test_CbAttr,
};


/*
--------------------------------------------------------------------------------
Transport Format.
*/
static	char *			_gAttr_TransportFormatSet[]={
	"TransportChannelType", 
	"transportChannelIdentity"
};

static	_t_xml_desc *	_gChild_TransportFormatSet[] = {
	&_gDesc_DedicatedTransChTFS,
	&_gDesc_CommonTransChTFS
};

static 	_t_xml_desc 	_gDesc_TransportFormatSet = {
	/* Name */
	"TransportFormatSet",

	/* Attribute */
	{2, _gAttr_TransportFormatSet},
	
	/* Children */
	{2, _gChild_TransportFormatSet},

	/* CallBack */
	(void * (*)())_test_CbChild,
	(void *	(*)())_test_CbAttr,
};

/*
--------------------------------------------------------------------------------
TFS.
*/
static	_t_xml_desc *	_gChild_TFS[] = {
	&_gDesc_TransportFormatSet
};
static 	_t_xml_desc 	_gDesc_TFS = {
	/* Name */
	"TFS",
	
	/* Attribute */
	{0, NULL},

	/* Children */
	{1, _gChild_TFS},

	/* CallBack */
	NULL,
	NULL,
};

/*
--------------------------------------------------------------------------------
Root.
*/
#if 0
static	_t_xml_desc *	_gChild_Root[] = {
	&_gDesc_TFS
};
static	_t_xml_desc 	_gDesc_Root = {
	/* Name */
	"Root",
	
	/* Attribute */
	{0, NULL},

	/* CallBack */
	NULL,

	/* Children */
	1, _gChild_Root,
};
#endif

static 	int 	test_Read(const char * hFile, const char * hPath)
{
	_t_xml_stack_frame 	frame[128];
	_t_xml_stack 		stack;
	
	#if 0
	SXml2Reader_XPath(hFile, hPath);
	#endif

	#if 1
	_SXML_STACK_INIT(&stack, frame, 128, &_gDesc_TFS, NULL);
	_SXML_FRAME_SET_PARENT(&(frame[1]), &_gDesc_TFS);
	_SXML_FRAME_SET_COOKIE(&(frame[1]), NULL);
	
	SXml2Reader_Parse(hFile, &stack);
	#else
	SXml2_Reader_Gen(hFile, "tfs");
	#endif
	return 0;
}

int 	main(void)
{
	test_Read("./tfs.xml", "*");
	return 0;
}
